package main

import (
	"github.com/joho/godotenv"
	"github.com/rs/zerolog/log"
	"github.com/spf13/viper"
	"notabug.org/BigWaffleMonster/ip-checker-telegram-bot/pkg"
	"notabug.org/BigWaffleMonster/ip-checker-telegram-bot/pkg/controller"
	"notabug.org/BigWaffleMonster/ip-checker-telegram-bot/pkg/service"
)

func main() {
	if err := initConfig(); err != nil {
		log.Error().Err(err).Msg("Error initializing configs")
	}

	if err := godotenv.Load(); err != nil {
		log.Error().Err(err).Msg("Error loading env variables")
	}

	services := service.NewService()
	controllers := controller.NewController(services)

	pkg.TelegramBot(controllers)
}

func initConfig() error {
	viper.AddConfigPath("configs")
	viper.SetConfigName("config")

	return viper.ReadInConfig()
}
